$OpenBSD: patch-lib_Makefile,v 1.4 2010/07/02 02:54:59 naddy Exp $
--- lib/Makefile.orig	Wed Jun 30 02:15:15 2010
+++ lib/Makefile	Wed Jun 30 02:22:04 2010
@@ -42,6 +42,9 @@ endif
 # Library objects to be linked but not built by Makefile.common:
 LIBOBJECTS_X = util/shhopt.o util/nstring.o util/filename.o
 
+SHLIBOBJECTS = $(patsubst %.o, %.lo, $(LIBOBJECTS))
+SHLIBOBJECTS_X = $(patsubst %.o, %.lo, $(LIBOBJECTS_X))
+
 MANUALS3 = libnetpbm
 MANUALS5 = pbm pgm ppm pnm pam
 
@@ -80,6 +83,10 @@ extra_staticlib: $(EXTRA_STATICLIB)
 
 $(LIBOBJECTS): %.o: %.c importinc
 # Note that the user may have configured -I options into CFLAGS.
+	$(CC) -c $(INCLUDES) -DNDEBUG $(CFLAGS) \
+	  $(CFLAGS_PERSONAL) $(CADD) -o $@ $<
+
+$(SHLIBOBJECTS): %.lo: %.c importinc
 	$(CC) -c $(INCLUDES) -DNDEBUG $(CFLAGS) $(CFLAGS_SHLIB) \
 	  $(CFLAGS_PERSONAL) $(CADD) -o $@ $<
 
@@ -107,7 +114,7 @@ endif
 
 ifeq ($(NETPBMLIBTYPE),unixshared)
 # The libxxx.so link is needed to link the executables.
-libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
+libnetpbm.$(NETPBMLIBSUFFIX): libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION)
 	rm -f $@
 	$(SYMLINK) $< $@
 # The $(SONAME) link is needed only to test the programs without
@@ -116,9 +123,9 @@ libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
 $(SONAME): libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)
 	rm -f $@
 	$(SYMLINK) $< $@
-libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): $(LIBOBJECTS) $(LIBOBJECTS_X)
-	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
-          $(SHLIB_CLIB) -lm $(LADD)
+libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION): $(SHLIBOBJECTS) $(SHLIBOBJECTS_X)
+	$(LD) $(LDSHLIB) -o $@ $(SHLIBOBJECTS) $(SHLIBOBJECTS_X) \
+	  $(SHLIB_CLIB) $(LADD)
 endif
 
 ifeq ($(NETPBMLIBTYPE),dll)
@@ -193,7 +200,7 @@ standardppmdfont.c:standard.ppmdfont
 compile.h:
 	$(SRCDIR)/buildtools/stamp-date >$@ || rm $@
 
-$(LIBOBJECTS_X): FORCE
+$(LIBOBJECTS_X) $(SHLIBOBJECTS_X): FORCE
 	@if [ ! -d $(dir $@) ] ; then mkdir $(dir $@) ; fi
 	$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
 		SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 
@@ -205,13 +212,9 @@ libpm.o: compile.h
 .PHONY: install.lib
 ifeq ($(NETPBMLIBTYPE),unixshared)
 # install a Unix-style shared library
-install.lib: $(PKGDIR)/lib $(PKGDIR)/link
-	cd $(PKGDIR)/lib ; rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).*
-	$(INSTALL) -c -m $(INSTALL_PERM_LIBD) \
-	  libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)  $(PKGDIR)/lib/
-	cd $(PKGDIR)/lib/ ; \
-          rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ); \
-          $(SYMLINK) libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(SONAME)
+install.lib: $(PKGDIR)/lib
+	$(BSD_INSTALL_DATA) \
+	  libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION) $(PKGDIR)/lib/
 endif
 ifeq ($(NETPBMLIBTYPE),dll)
 #install a Windows DLL shared library
@@ -241,13 +244,13 @@ install.hdr: $(INTERFACE_HEADERS:%=%_installhdr)
 # directory when you compile your programs.
 
 %_installhdr: $(PKGDIR)/include
-	$(INSTALL) -c -m $(INSTALL_PERM_HDR) \
+	$(BSD_INSTALL_DATA) \
 	  $(SRCDIR)/lib/$(@:%_installhdr=%) $(PKGDIR)/include/;
 
 .PHONY: install.staticlib
-install.staticlib: $(PKGDIR)/link
-	$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.$(STATICLIBSUFFIX) \
-	  $(PKGDIR)/link
+install.staticlib: $(PKGDIR)/lib
+	$(BSD_INSTALL_DATA) libnetpbm.$(STATICLIBSUFFIX) \
+	  $(PKGDIR)/lib
 
 # Install a shared library stub -- the ".so" file used at link time to
 # prepare a program for dynamically linking a library at run time 
